Skip to content

feat(rule): stop naming rule rollback on a plan that does not serve it - #435

Merged
theCodeDrift merged 3 commits into
plan-aware-recovery/2-checkfrom
plan-aware-recovery/3-revisions
Oct 1, 2026
Merged

theCodeDrift merged 3 commits into
plan-aware-recovery/2-checkfrom
plan-aware-recovery/3-revisions

Conversation

@theCodeDrift

@theCodeDrift theCodeDrift commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Stack (root → tip):

Stack 3 of 3 (tip), merging forward. Based on #434. Archives cli-plan-aware-recovery.

What this PR does

  • rule revisions still lists revisions on every plan, since the service serves the listing to all of them. When restoreRules is false, only the closing line changes. It says "Rolling back is not included in your organization's plan; earlier versions of this rule are in the repository's git history." instead of naming rule rollback. --json is unchanged.
  • Still not a gate. A new test runs rule restore with whoami reporting restoreRules: false. It asserts that the CLI still calls the service's restore endpoint and passes the refusal through.
  • The recover-rule agent recipe goes to v3. It tells an agent to check what check or rule revisions offered before running restore or rollback, and to follow the git steps when either says the plan excludes recovery.
  • Extends the changeset from unit 2.
  • Archives the change into the cli-rule-recovery, cli-check and cli-rule-reconciliation specs.

What to review

  • The archive was checked for dropped scenarios. I recorded every standing scenario title in the three specs before archiving and compared after. None were lost. cli-check gained 1 and cli-rule-recovery gained 8. The four MODIFIED requirements were copied verbatim from the standing specs before editing, and all four applied (none were skipped over a title mismatch).
  • The "plan excludes rollback" test in rule-recovery.test.ts fails if the restoreRules === false branch is removed. I checked that by reverting the branch temporarily.

Fixes #425

@theCodeDrift

Copy link
Copy Markdown
Member Author

@claude /review

@claude

claude Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Claude finished @theCodeDrift's task in 7m 40s —— View job


Review: feat(rule): stop naming rule rollback on a plan that does not serve it

Review mode: incremental — read 0 prior review thread(s) before reviewing. .prior-review.json contained no reviews, review threads, or top-level comments beyond the trigger comment itself, so this is the first review of this PR.

  • Read .prior-review.json (data only)
  • Gather PR diff (gh pr diff 435) and metadata
  • Read the changed source (rules.ts, recover.ts, recovery-advice.ts, identity.ts, org.ts, plan-check.ts) and the full test file
  • Cross-check the archived spec deltas against the final openspec/specs/* files for dropped/renamed requirements
  • Assess correctness, cleanup, altitude, and CLAUDE.md conventions

Summary

This is a small, well-scoped unit and I did not find any correctness bugs.

  • rules.ts's revisionsCommand now threads identity.restoreRules alongside the revisions() result through runForIssuedRule. The await revisions(...) still throws into the same try/catch in runForIssuedRule, so error handling is unchanged. --json output is untouched (revisionsOutputSchema.parse({ success: true, ...list }) never sees restoreRules), matching the spec's "--json output SHALL NOT change" and the new "No extra request is made" scenario — identity.restoreRules rides on the single whoami call already made inside resolveIdentity, no second request is added.
  • describeRevisions(list, restoreRules) in recover.ts only changes the closing line on restoreRules === false; the listing itself, the "no revisions" early return, and the "no current revision" line are all unaffected. restore/rollback in the same file don't reference restoreRules at all, consistent with "this is a suggestion, never a gate" — confirmed by the new test still asks the service to restore when whoami says the plan excludes it, which asserts restoreCalled() is true even with restoreRules: false.
  • Archive integrity check: I compared the archived delta (openspec/changes/archive/2026-09-30-cli-plan-aware-recovery/specs/*/spec.md) against the final openspec/specs/*/spec.md. All three MODIFIED requirement titles match exactly (Check never writes to the rules tree, Reconcile verdicts are applied per engine, A copy of an issued rule does not run as a local rule, Rule revisions lists what rollback can choose from), and every prior scenario under those requirements is still present verbatim in the final spec plus the new ones — no scenario was silently dropped by the archive, which is the exact failure mode called out in this repo's CLAUDE.md ("A spec delta REPLACES a requirement... Anything you leave out is deleted, silently").
  • Test coverage for the new behavior looks adequate: plan-excludes-rollback listing, plan-includes-rollback listing, and the "still calls the service" non-gating case are all covered in rule-recovery.test.ts.

Minor, non-blocking observation

  • packages/cli/src/agent/recover-rule.md: the "Rolling back" step-by-step (steps 1–3) doesn't itself repeat the plan check before step 3 ("Roll back to it"); the instruction to check the plan lives only in the "Goal" section above and in "When the plan does not include recovery" near the bottom. In practice step 1's output (rule revisions) would already show the "Rolling back is not included..." line, so an agent following the doc literally still sees the signal before running rollback — this is a documentation-clarity nit, not a functional gap, and I'm not confident it's worth a change.

No other findings. Nice attention to detail on the archive-scenario check called out in the PR description — it held up under a second look.

@theCodeDrift
theCodeDrift force-pushed the plan-aware-recovery/3-revisions branch from 60d0995 to 9b58d36 Compare October 1, 2026 03:26
@theCodeDrift

Copy link
Copy Markdown
Member Author

Re: @claude[bot] — the "Rolling back" steps in agent/recover-rule.md don't repeat the plan check before rule rollback
#435 (comment)

Fixed in 512bd7c, and the gap was larger than the review suggested. Step 1 runs rule revisions --json, and the "Rolling back is not included" line is printed only without --json, so an agent following the recipe never saw it. Step 1 now checks the plan first. It reads check's notices and failures, which --json does carry, or runs rule revisions once without --json. The recipe also says plainly which output carries the signal. --json itself is unchanged, as the spec requires.

— AI Coding Agent

@theCodeDrift
theCodeDrift added this pull request to stack #436 October 1, 2026 05:38
@theCodeDrift
theCodeDrift force-pushed the plan-aware-recovery/3-revisions branch from 512bd7c to 49d278d Compare October 1, 2026 05:38
@theCodeDrift
theCodeDrift merged commit cee92ae into main Oct 1, 2026
4 checks passed
@theCodeDrift
theCodeDrift deleted the plan-aware-recovery/3-revisions branch October 1, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offer restore and rollback only when the plan includes them, using whoami's entitlements

1 participant